package router

import (
	"github.com/gin-gonic/gin"
	"log"
)

type formLogin struct {
	username string `from:"username" binding: "required"`
	password string `from:"password" binding: "required"`
}

/**
 * 表单绑定
 */
func Bind() {
	engine := gin.Default()

	engine.POST("/login", func(c *gin.Context) {
		var form formLogin
		if c.ShouldBind(&form) == nil {

			c.JSON(200, gin.H{
				"status": 200,
				"result": "success",
			})
		} else {
			c.JSON(400, gin.H{
				"status": 400,
			})
		}
	})

	err := engine.Run(":9000")
	if err != nil {
		log.Fatal(err.Error())
	}
}
